home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
ast_comp
/
sql.txt
< prev
next >
Wrap
Text File
|
1993-07-04
|
46KB
|
2,261 lines
#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:
# "End of shell archive."
# Contents: Cain.SQL Makefile README ddf.h dsl.l dsl.y ed0 ed1 ed2
# gtok.h parser.c phm.c rwsearch.c testpar tf.l tmprws.h tpar.c
# vtest2
# Wrapped by meyerweg@ndbs on Tue Oct 31 11:42:22 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f Cain.SQL -a "${1}" != "-c" ; then
echo shar: Will not over-write existing file \"Cain.SQL\"
else
echo shar: Extracting \"Cain.SQL\" \(1880 characters\)
sed "s/^X//" >Cain.SQL <<'END_OF_Cain.SQL'
XPath: incas!unido!mcsun!uunet!cuc1!lcain
XFrom: lcain@cuc1.UUCP (Leroy Cain)
XNewsgroups: comp.databases
XSubject: ISO/ANSI SQL Parser in LEX/YACC
XKeywords: ISO ANSI SQL LEX YACC
XMessage-ID: <2137@cuc1.UUCP>
XDate: 15 Sep 89 21:50:08 GMT
XOrganization: Columbia Union College; Takoma Park, MD 20912
XLines: 42
XPosted: Fri Sep 15 22:50:08 1989
X
X
XHi Guys
X
XThe LEX/YACC parser for ANSI SQL is almost done. What I am look for
Xnow is several of you that are familiar the ANSI specification to
Xreview my work before I release it, so that it will be as error free
Xas possible.
X
XFor the rest of you here are some highlights of this package.
X
XThis is an parser for ISO/ANSI SQL written useing LEX, YACC, and C
Xit provide syntax check and a frame for building a completed
Xquery processor.
XSee ANSI X3.135-1986 and ANSI X3.135.1-198x Addendum 1
X ISO 9075-1987(E) Addendum 1
X
XUnlike the previous SQL parser I posted, this one can be process with
Xa normal YACC so everyone should be able to use it.
X
XThere are three parts:
X 1. Module -- This processes the module specification and
X produces function calls to which ever language
X is specificied.
X 2. Embedded -- This processes the embedded SQL specification and
X produces function calls to which ever language
X is specificied.
X 3. Internal -- This processes SQL command passed to the function
X interface.
X
XNotes:
X In Module and Embedded you add the code to produce the function
X calls.
X Language specificied for use with Module and Embedded are C, COBOL,
X FORTRAN, Pascal, PL/1.
X C as a possible langauge for Module and Embedded is not specificied
X in the ANSI specs. This is the only place I deveated.
X
X
XMS-DOS Just say NO!!!!! OS/2 Why????
XLeroy Cain; Columbia Union College; Mathematical Sciences
Department
X7600 Flower Ave. WH406; Takoma Park, Md 20912
X(301) 891-4172 uunet!cucstud!lcain
X
END_OF_Cain.SQL
if test 1880 -ne `wc -c <Cain.SQL`; then
echo shar: \"Cain.SQL\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f Makefile -a "${1}" != "-c" ; then
echo shar: Will not over-write existing file \"Makefile\"
else
echo shar: Extracting \"Makefile\" \(510 characters\)
sed "s/^X//" >Makefile <<'END_OF_Makefile'
X# Makefile for Data sublanguages
X# written 1985 by Leroy Cain
X# modified 1989 by Klaus Meyer-Wegener
X
XALL: tpar
X
Xtpar : tpar.c parser.c y.tab.o
X cc -o tpar tpar.c parser.c y.tab.o -ll
X
Xy.tab.o: y.tab.c lex.yy.c parser.h gtok.h
X cc -c y.tab.c
X
Xy.tab.c: dsl.y
X yacc -vd dsl.y
X
Xlex.yy.c: dsl.l
X lex dsl.l
X ./ed0
X
Xparser.h: y.tab.h tmprws.h phm
X ./ed1
X sort +2 -3 y.h | ./phm
X ./ed2 `wc y.h`
X
Xphm: phm.c
X cc -o phm phm.c
X
Xtf: tf.l
X lex -t tf.l > tf.yy.c
X cc -o tf tf.yy.c
X
Xtest: tf vtest2 tpar
X tf < vtest2 | tpar
END_OF_Makefile
if test 510 -ne `wc -c <Makefile`; then
echo shar: \"Makefile\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f README -a "${1}" != "-c" ; then
echo shar: Will not over-write existing file \"README\"
else
echo shar: Extracting \"README\" \(1879 characters\)
sed "s/^X//" >README <<'END_OF_README'
XThis directory contains the parser for DDF. The components are as follows
X
XMakefile
XREADME
X
XPROGRAM FILES
Xdsl.l Lex for parser
Xdsl.y Yacc for parser
Xparser.c Main parser function
Xrwsearch.c Reserved word table search functions
Xtpar.c Main for testing parser
X
XINCLUDE FILES
Xtmprws.h template for parser.h; filled with data generated from
X y.tab.h (output of yacc)
Xddf.h definition of type DDFRUN
Xgtok.h Parser tree token definitions
X
XAUXILIARY SHELL SCRIPTS AND PROGRAMS
Xed0 edit script for lex; executed after generating lex.yy.c
X from dsl.l; removes the definitions of makros input(),
X output(c), and unput(c) - they are redefined in parser.c
Xed0.out stdout protocol of ed0 actions
Xed1 edit script for yacc; modifies the output y.tab.h of
X yacc to produce y.h; y.h is sorted and piped through phm
X to produce rnums and rwords
Xed1.out stdout protocol of ed1 actions
Xed2 edit script for yacc; generates file nt containing 'wc y.h';
X opens tmprws.h, inserts nt, rnums, and rwords in
X appropriate places, and writes parser.h
Xed2.out stdout protocol of ed2 actions
Xphm.c reads y.h to generate rnums and rwords
Xphm result of cc -o phm phm.c
X
XTEMPFILES
Xlex.yy.c lex output generated from dsl.l
Xy.tab.c yacc program ( yyparse() ) generated from dsl.y
Xy.tab.h include with token definitions generated by yacc
Xy.output states and transitions documented by yacc
Xrnums
Xrwords
Xnt
Xparser.h parser related tables, defines and variables;
X generated by ed2
Xy.tab.o object module yyparse
Xparser.o object module parse
X
XTEST
Xvtest2 list of sql statements
Xtf.l lex definition to eliminate numbers from vtest2
Xtf.yy.c lex output generated from tf.l
Xtf result of cc -0 tf tf.yy.c -ll
Xtpar main test program; reads stdin and writes pt_file
Xtestpar shell script to execute tpar: tf < vtest2 | tpar
Xpt_file parse tree test output file
END_OF_README
if test 1879 -ne `wc -c <README`; then
echo shar: \"README\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f ddf.h -a "${1}" != "-c" ; then
echo shar: Will not over-write existing file \"ddf.h\"
else
echo shar: Extracting \"ddf.h\" \(94 characters\)
sed "s/^X//" >ddf.h <<'END_OF_ddf.h'
Xtypedef struct sql_run
X{
X unsigned char *par_buf;
X int buf_len;
X} DDFRUN;
END_OF_ddf.h
if test 94 -ne `wc -c <ddf.h`; then
echo shar: \"ddf.h\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f dsl.l -a "${1}" != "-c" ; then
echo shar: Will not over-write existing file \"dsl.l\"
else
echo shar: Extracting \"dsl.l\" \(1806 characters\)
sed "s/^X//" >dsl.l <<'END_OF_dsl.l'
X/*
XDistributed data base Facilitator
XParser
XVersion 1.0
XCopyright 1986 Columbia Union College
XBy Leroy G. Cain
X*/
X%{
X#include "string.h"
X#include "parser.h"
X#include "rwsearch.c"
X%}
XD [0-9]
XE [Ee][-+]?{D}+
X%%
X[a-zA-Z]+
X{
Xint rw;
X
X if((rw= rwsearch(yytext)) == IDENTIFIER )
X {
X yylval.nsbuf = strcpy(scratch,yytext);
X }
X return rw;
X}
X
X"$"[a-zA-Z_][a-zA-Z0-9_#@]* return( PARM );
X
X[a-zA-Z_][a-zA-Z0-9_#@]* {
X yylval.nsbuf = strcpy (scratch, yytext); /* KMW */
X return IDENTIFIER ;
X}
X
X\"[^\"]* |
X\'[^\']*
X{
X if(yytext[yyleng-1] == '\\')
X yymore();
X else
X {
X yytext[yyleng++] = input();
X yytext[yyleng] = '\0';
X return( STRING );
X }
X}
X
X{D}+ return ( INTEGER );
X
X{D}+"."{D}*({E})? |
X{D}+"."{D}+({E})? |
X{D}+{E} return ( REAL );
X
X":" return ':' ;
X";" return ';' ;
X".*" return ALLFIELDS ;
X"." return '.' ;
X"," return ',' ;
X"!" return NOT ;
X"!=" return NE ;
X"<=" return LE ;
X">=" return GE ;
X"<" return LT ;
X"!<" return NLT ;
X">" return GT ;
X"!>" return NGT ;
X"(" return '(' ;
X")" return ')' ;
X">>" return RIGHTSHIFT ;
X"<<" return LEFTSHIFT ;
X"|" return '|' ; /* Bit or */
X"||" return E_OR ; /* or */
X"^" return '^' ; /* Bit ex-or */
X"&" return '&' ; /* Bit and */
X"&&" return E_AND ; /* and */
X"~" return '~' ; /* Ones compliment */
X"`" return '`' ; /* Sematic control */
X"]" return ']' ;
X"[" return '[' ;
X"=" return EQ ;
X"+" return '+' ;
X"-" return '-' ;
X"*" return '*' ;
X"**" return PWR ;
X"/" return '/' ;
X"%" return '%' ; /* Modulus */
X"?" return '?' ;
X[/] return( ILLEGAL );
X[ \n\t\r] ;
X%%
END_OF_dsl.l
if test 1806 -ne `wc -c <dsl.l`; then
echo shar: \"dsl.l\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f dsl.y -a "${1}" != "-c" ; then
echo shar: Will not over-write existing file \"dsl.y\"
else
echo shar: Extracting \"dsl.y\" \(17429 characters\)
sed "s/^X//" >dsl.y <<'END_OF_dsl.y'
X/*
XDistributed Database Facilitator Parcer
XVersion 1.0
XBy Leroy G. Cain
X1985 Columbia Union College
X*/
X%union
X{
X int stype;
X char *nsbuf;
X}
X%token ADD
X%token ALL
X%token ALLOWED
X%token AFTER
X%token ALTER
X%token AND
X%token ANY
X%token AS
X%token ASC
X%token AT
X%token AUDIT
X%token BEFORE
X%token BBEGIN
X%token BETWEEN
X%token BY
X%token CHECK
X%token CLOSE
X%token COMMENT
X%token COMMIT
X%token COMPOSITE
X%token CONSTRAINT
X%token CREATE
X%token DATABASE
X%token DEFAULT
X%token DELETE
X%token DESC
X%token DISTINCT
X%token DIVIDEBY
X%token DOMAIN
X%token DROP
X%token DUMP
X%token END
X%token ELSE
X%token EXISTS
X%token FOR
X%token FOREIGN
X%token FRAGMENT
X%token FROM
X%token GRANT
X%token GROUP
X%token HAVING
X%token IDENTIFIES
X%token IF
X%token IN
X%token INDEX
X%token INFO
X%token INSERT
X%token INTO
X%token INTERSECT
X%token IS
X%token LIKE
X%token LOCK
X%token MINUS
X%token MODE
X%token MODIFY
X%token NOT
X%token NULLN
X%token NULLS
X%token OF
X%token ON
X%token OPEN
X%token OPTION
X%token OR
X%token ORDER
X%token OUTER
X%token PRIMARY
X%token PROGRAM
X%token RANGE
X%token REPAIR
X%token RESTORE
X%token REVOKE
X%token ROLLBACK
X%token ROLLFORWARD
X%token SELECT
X%token SET
X%token SHOW
X%token SNAPSHOT
X%token START
X%token STORE
X%token SYNC
X%token SYNONYM
X%token TABLE
X%token THEN
X%token TO
X%token TYPE
X%token VALUES
X%token VIEW
X%token UNION
X%token UNIQUE
X%token UPDATE
X%token WHERE
X%token WORK
X%token WITH
X/*
X*/
X%token ALLFIELDS
X%token <nsbuf> IDENTIFIER
X%token INTEGER
X%token ILLEGAL
X%token REAL
X%token STRING
X%token PARM
X%left ';'
X%left WHERE
X%left OR
X%left AND
X%left ','
X%right ASSIGN
X%right TCOL
X%left '?'
X%left E_OR
X%left E_AND
X%left '|'
X%left '^'
X%left '&'
X%left NLT NGT LT GT EQ GE LE NE
X%left RIGHTSHIFT LEFTSHIFT
X%left '+' '-'
X%left '*' '/' '%' PWR
X%right UMINUS '~' PNOT
X%left PORDER
X%left '`'
X%left '.'
X
X
X%{
Xstatic long flag;
Xstatic short sqy_flag;
X
Xstatic char path_name[1024];
Xstatic char scratch[1024];
X
X#include "gtok.h"
X#define BEXPR { sqy_flag = 0; }
X%}
X%%
Xdsl:
X statement ';'
X {puttok(T_ROOT);puttok(0);puttok(0);puttok(T_ENDCOMMAND);}
X | STORE PROGRAM prog_name '(' parm_list ')'stats ';' END STORE ';'
X ;
X
Xstats:
X statement
X | stats ';' statement
X ;
X
X /*
Xtrigger_list:
X trigger
X | trigger_list ',' trigger
X |error
X | trigger_list error trigger
X | trigger_list ',' error
X ;
X */
Xstatement:
X { puttok(0300);} alter
X | { puttok(0301);} audit
X | { puttok(0302);} begin
X | { puttok(0303);} check
X | { puttok(0304);} close
X | { puttok(0305);} comment
X | { puttok(0306);} commit
X | { puttok(0307);} create
X | { puttok(0310);} delete
X | { puttok(0311);} drop
X | { puttok(0312);} dump
X | { puttok(0313);} grant
X | { puttok(0314);} info
X | { puttok(0315);} insert
X | { puttok(0316);} lock
X | { puttok(0317);} open
X | { puttok(0320);} rollback
X | { puttok(0321);} rollforward
X | { puttok(0322);} repair
X | { puttok(0323);} restore
X | { puttok(0324);} revoke
X | { puttok(0325);} select
X | { puttok(0326);} set
X | { puttok(0327);} start
X | { puttok(0330);} sync
X | { puttok(0331);} update
X ;
X
Xstart:
X prog_name '(' expr_list ')'
X /*
X | START INTEGER '(' parm_list ')'
X */
X ;
X
Xparm_list:
X parm
X | parm ',' parm_list
X ;
X
Xparm:
X parm_name
X | parm_name EQ expr %prec ASSIGN
X ;
X
X/*
XData Manipulation
X*/
X
Xdelete:
X DELETE FROM rec_alias where_clause /* Set where flag */
X ;
X
Xinsert:
X INSERT INTO rec_alias '(' field_list ')' icond
X | INSERT INTO rec_alias icond
X ;
X
Xupdate:
X UPDATE rec_alias set_show where_clause /* Set where flag */
X ;
X
Xrec_alias:
X path
X | path alias
X ;
X
Xicond:
X FROM filename
X | select_statement
X | VALUES '(' const_list ')'
X ;
X
Xset_show:
X SHOW setelements
X | SET setelements
X ;
X
Xsetelements:
X setelement
X | setelements ',' setelement
X ;
X
Xsetelement:
X field EQ expr %prec ASSIGN
X | field EQ select_statement %prec ASSIGN
X | '[' field_list ']' EQ '[' expr_list ']' %prec ASSIGN
X | '[' field_list ']' EQ select_statement %prec ASSIGN
X ;
X
X/*
XQuery Langauge
X*/
X
Xselect:
X select_expr order_clause into_clause
X ;
X
Xselect_expr:
X select_statement
X | select_expr UNION any select_statement
X | select_expr MINUS select_statement
X | select_expr DIVIDEBY select_statement
X | select_expr INTERSECT select_statement
X | '(' select_expr ')'
X ;
X
Xorder_clause:
X | ORDER BY norder_list
X ;
X
Xinto_clause:
X | INTO filename
X ;
X
Xselect_statement:
X { puttok(T_TLEND); }
X select_clause
X FROM from_item_list
X select_options
X { puttok(T_QLEND); }
X ;
X
Xorder_list:
X path orderdir %prec PORDER
X | order_list ',' path orderdir
X ;
X
Xnorder_list:
X/*
X INTEGER orderdir %prec PORDER
X*/
X expr orderdir %prec PORDER
X/*
X | path orderdir %prec PORDER
X*/
X | norder_list ',' norder_list
X ;
X
Xselect_clause:
X SELECT unique sellist
X | SELECT unique '*'
X ;
X
Xfrom_item_list:
X from_item
X | from_item_list ',' from_item_list
X ;
X
Xfrom_item:
X rec_alias
X | OUTER rec_alias
X | OUTER '(' from_item_list ')'
X ;
X
Xselect_options:
X | WHERE predicate /* Set where flag */
X | WHERE predicate group_clause
X | group_clause
X ;
X
Xgroup_clause:
X GROUP BY path_list
X | GROUP BY path_list HAVING predicate /* Set having flag */
X ;
X
Xunique:
X | ALL
X | DISTINCT
X | UNIQUE
X ;
X
Xsellist:
X selelement {puttok(T_RESDOM);}
X | sellist ',' selelement {puttok(T_RESDOM);}
X ;
X
Xselelement:
X record ALLFIELDS
X | expr
X | expr STRING
X ;
X
Xpredicate:
X condition
X | condition AND predicate
X | condition OR predicate
X | NOT predicate %prec PNOT
X | '(' predicate ')'
X | IF predicate THEN predicate else_pred
X ;
X
Xelse_pred:
X |ELSE predicate
X ;
X
Xcondition:
X expr
X | expr not IN in_sel_expr /* singler flag */
X | '[' path_list ']' not IN in_sel_expr
X | expr IS not NULLN
X | expr IS not DEFAULT
X | expr not BETWEEN expr AND expr
X | expr not LIKE const /* Like flag */
X | EXISTS '(' select_statement ')'
X ;
X
Xnot:
X |NOT
X ;
X
Xany:
X |ALL
X |ANY
X ;
X
Xin_sel_expr:
X '(' select_statement ')'
X | const_recs
X ;
X
Xcond_sel_expr:
X expr
X | '(' select_statement ')'
X {if (sqy_flag) yyerror ("Illegal subquery"); else sqy_flag = 1;}
X ;
X
Xconst_recs:
X '(' const_list ')'
X | '[' const_rec_list ']'
X ;
X
Xconst_rec_list:
X '(' const_list ')'
X | const_rec_list ',' '(' const_list ')'
X ;
X
Xpath_list:
X path
X | path_list ',' path
X ;
X
Xfield_list:
X field
X | field_list ',' field
X ;
X/*
Xpath is a field or record path.
Xnode.database.record -- for records
Xnode.database.record.field -- for fields
X*/
Xpath:
X path_e_list {puttok(T_VAR);putvar(path_name);*path_name='\0';}
X | path_e_list '[' element_name ']'
X ;
X
Xpath_e_list:
X path_element
X | path_element {strcat(path_name,".");} '.' path_e_list
X ;
X
Xelement_name:/* element_name flag */
X norder_list
X ;
X
Xorderdir:
X | DESC
X | ASC
X ;
X
Xconst_list:
X const
X | const_list ',' const
X ;
X
Xexpr:
X expr '`' s_control /* Semantic control */
X | '-' expr %prec UMINUS {puttok(T_NEG);}/* negate */
X | expr '+' expr {puttok(T_ADD);}/* add */
X | expr '-' expr {puttok(T_SUB);}/* subtract */
X | expr '*' expr {puttok(T_MUL);}/* multiply */
X | expr '/' expr {puttok(T_DIV);}/* divide */
X | expr '%' expr {puttok(T_MOD);}/* modulus */
X | expr PWR expr {puttok(T_ADD);}/* power */
X | expr '?' else_part
X | '~' expr /* ones compliment */
X | expr RIGHTSHIFT expr /* bit shift right */
X | expr LEFTSHIFT expr /* bit shift left */
X | expr '^' expr /* exclusive or */
X | expr '|' expr /* or */
X | expr '&' expr /* and */
X | expr E_OR expr /* or */
X | expr E_AND expr /* and */
X | expr NLT cond_sel_expr {puttok(T_NLT);}
X | expr NGT cond_sel_expr {puttok(T_NGT);}
X | expr LT any cond_sel_expr {puttok(T_LT);}
X | expr GT any cond_sel_expr {puttok(T_GT);}
X | expr EQ any cond_sel_expr {puttok(T_EQ);}
X | expr GE cond_sel_expr {puttok(T_GE);}
X | expr LE cond_sel_expr {puttok(T_LE);}
X | expr NE any cond_sel_expr {puttok(T_NE);}
X | '(' expr ')' /* parenthesis */
X | const
X | path
X | function
X ;
X
Xelse_part:
X expr ':' expr %prec TCOL
X ;
X
Xconst:
X INTEGER {puttok(T_INT4); putint(yytext);}
X | REAL {puttok(T_FLT8); putreal(yytext);}
X | STRING {puttok(T_CHAR); putstr(yytext);}
X | DEFAULT
X | NULLN
X | PARM
X ;
X
Xfunction:
X fname '(' '*' ')'
X | fname '(' expr_list ')'
X | fname '(' UNIQUE path ')'
X ;
X
Xexpr_list:
X expr
X | expr_list ',' expr
X ;
X
X/*
XData Definition Language
X*/
Xcreate:
X CREATE cluster TABLE path tfd_list with_clause
X | CREATE VIEW view_name vfd AS select_statement with_clause
X | CREATE FRAGMENT view_name vfd AS select_statement with_clause
X | CREATE SNAPSHOT view_name vfd AS select_statement with_clause
X | CREATE SYNONYM syn_name FOR path
X | CREATE unique cluster INDEX index_name
X ON path '(' order_list ')' with_clause
X | CREATE DATABASE dbname TYPE dbtype ON hname with_clause
X | CREATE DOMAIN domain_name_list IS domain_types
X defaults domain_restrict
X | CREATE TYPE type_name IS
X | CREATE CONSTRAINT constr_name trigger_list CHECK predicate
else_clause
X ;
X
Xalter:
X ALTER TABLE path alter_list with_clause
X | ALTER TABLE path path with_clause
X ;
X
Xdrop:
X DROP INDEX index_name
X | DROP object_type path
X ;
X
Xcomment:
X COMMENT ON path
X | COMMENT ON path IS comment_str
X ;
X
Xinfo:
X INFO
X ;
X
Xcomment_str:
X STRING
X | STRING ',' STRING
X ;
X
Xtrigger_list:
X trigger
X | trigger_list ',' trigger
X ;
X
Xtrigger:
X AT event
X | AFTER event OF path FROM path
X | BEFORE event OF path FROM path
X ;
X
Xevent:
X COMMIT
X | DELETE
X | INSERT
X | UPDATE
X ;
X
Xelse_clause:
X | ELSE statement
X ;
X
Xindex_name: path;
X
Xcluster:
X | IDENTIFIER
X /*
X |CLUSTERED |NONCLUSTERED
X */
X ;
X
Xview_name:
X record
X | user '.' record
X ;
X
Xwith_clause:
X |WITH option_list
X ;
X
Xoption_list:
X option
X | option ',' option_list
X ;
X
Xoption:
X IDENTIFIER
X | IDENTIFIER IDENTIFIER
X | IDENTIFIER EQ const
X/*
Xreconfigure| check option |logfile = "file_name"
X*/
X ;
X
Xtfd_list:
X primary_key
X foreign_keys
X field_dis
X ;
X
Xfield_dis:
X '(' tfd_fields ')'
X ;
X
Xprimary_key:
X | PRIMARY '(' primary_keys ')'
X ;
X
Xprimary_keys:
X field
X | primary_keys ',' field
X ;
X
Xforeign_keys:
X | foreign_keys foreign_key
X ;
X
Xforeign_key:
X FOREIGN '(' f_key IDENTIFIES path
X nulls
X DELETE OF path effect
X UPDATE OF path effect')'
X ;
X
X/*
Xf_keys:
X f_key
X | f_keys ',' f_key
X ;
X*/
X
Xnulls:
X NULLS ALLOWED
X | NULLS NOT ALLOWED
X ;
X
Xtfd_fields:
X tfd
X | tfd_fields ',' tfd
X ;
X
Xtfd:
X field o_domain_name
X | field '(' field_list ')' o_domain_name
X ;
X
Xo_domain_name:
X |domain_name
X ;
X
Xtype_name:
X IDENTIFIER
X /*
XBase types:
X boolean(bit)|
X char|short_integer|long_integer|
X byte|short_word|long_word|
X float|double|extended|bcd|bcdflt
Xpredefine extentions:
X char|byte[1-2,000,000,000]
X [short|long]_[integer|word][1-2,000,000,000]
X float|double|extended[1-2,000,000,000]
X bcd|bcdflt[1-2,000,000,000]
X date_[]
X money
X time_[m,ap,sm,sap,micro]
X */
X ;
X
Xdomain_name_list:
X domain_name
X | domain_name_list ',' domain_name
X ;
X
Xdomain_types:
X domain_type
X | '(' domain_type_list ')'
X ;
X
Xdefaults:
X | DEFAULT
X ;
X
Xdomain_restrict:
X where_clause
X | select_statement
X ;
X
Xdomain_type_list:
X | domain_type_list ',' domain_type
X ;
X
Xdomain_type:
X type_name
X | type_name '(' i_list ')'
X ;
X
Xi_list:
X INTEGER
X | i_list ',' INTEGER
X ;
X
Xvfd:
X | '(' vfd_list ')'
X ;
X
Xvfd_list:
X field
X | vfd_list ',' field
X ;
X
Xalter_list:
X alteration
X | alter_list ',' alteration
X ;
X
Xalteration:
X ADD '(' a_tfd_fields ')'
X | DROP vfd
X | MODIFY '(' m_tfd_fields ')'
X ;
X
Xa_tfd_fields:
X tfd before
X | a_tfd_fields ',' tfd before
X ;
X
Xm_tfd_fields:
X field tfd
X | m_tfd_fields ',' field tfd
X ;
X
Xbefore:
X | BEFORE field
X ;
X
Xeffect:
X IDENTIFIER
X/*
X CASCADES | RESTRICTED | NULLIFIES
X*/
X ;
X/*
X*/
Xobject_type:
X DATABASE| DOMAIN| PROGRAM| SYNONYM| TYPE| TABLE| VIEW
X ;
X/*
XSecurity
X*/
X
Xgrant:
X GRANT privileges gr_on TO users at_option between_option
X on_option where_option wgo
X ;
X
Xat_option:
X |AT terminal_list
X ;
X
Xbetween_option:
X |BETWEEN time1 AND time2
X ;
X
Xon_option:
X |ON day1 AND day2
X ;
X
Xwhere_option:
X |WHERE predicate
X ;
X
Xwgo:
X | WITH GRANT OPTION
X ;
X
Xterminal_list:
X tty
X | tty ',' terminal_list
X ;
X
Xrevoke:
X REVOKE privileges gr_on FROM users
X ;
X
Xprivileges:
X | privileg
X | privileges ',' privileg
X ;
X
Xprivileg:
X priv_name
X | priv_name '(' field_list ')'
X ;
X
Xgr_on:
X | ON object_type objects
X ;
X
Xusers:
X user
X | users ',' user
X ;
X
Xobjects:
X IDENTIFIER
X | objects ',' IDENTIFIER
X ;
X
X/*
XTransaction Management
X*/
X
Xlock:
X LOCK TABLE path IN mode MODE
X ;
X
Xbegin:
X BBEGIN work
X ;
X
Xcommit:
X COMMIT work
X ;
X
Xrollback:
X ROLLBACK work
X | ROLLBACK SYNC
X ;
X
Xrollforward:
X ROLLFORWARD path FROM path roll_op
X ;
X
Xroll_op:
X |TO STRING time
X ;
X
Xtime:
X |STRING
X ;
X
Xsync:
X SYNC
X ;
X
Xwork:
X |WORK
X ;
X/*
XAcess management
X*/
X
X
Xclose:
X CLOSE dbname
X ;
X
Xopen:
X OPEN dbname password
X ;
X
X
Xpassword:
X |IDENTIFIER
X ;
X/*
XDataBase Maintaince and Configuration
X*/
Xaudit:
X AUDIT into_clause path_list
X from_clause where_clause /* Set audit flag */
X ;
X
Xcheck:
X CHECK
X ;
X
Xdump:
X DUMP DATABASE dbname to_clause
X | DUMP TABLE dbname to_clause
X ;
X
Xrepair:
X REPAIR
X ;
X
Xrestore:
X RESTORE DATABASE dbname rfrom_clause
X | RESTORE TABLE dbname rfrom_clause
X ;
X
Xto_clause:
X |TO filename
X ;
X
Xrfrom_clause:
X |FROM filename
X ;
X
Xset:
X SET option_list
X ;
X
Xwhere_clause:
X | WHERE predicate
X ;
X
Xfrom_clause:
X | FROM path_list
X ;
X/*
XCONSTRAND IDENTIFIERS
X*/
Xmode:
X IDENTIFIER
X/* check
X SHARE | EXCLUSIVE | OFF
X*/
X ;
X
Xpriv_name:
X IDENTIFIER
X | ALTER | CREATE | DELETE | DUMP | RESTORE
X | DROP | INSERT | LOCK | SELECT | UPDATE
X/* check
X | CREATE_TABLE | CREATE_DATABASE
X | CREATE_INDEX | ALL
X*/ ;
X
Xs_control:
X IDENTIFIER
X ;
X/*
XIDENTIFIERS
X*/
Xalias: IDENTIFIER;
Xconstr_name: IDENTIFIER;/* Constraint Name */
Xday1: IDENTIFIER;
Xday2: IDENTIFIER;
Xdbtype: PARM | IDENTIFIER;/* Database type */
Xdbname: PARM | IDENTIFIER;/* Database name */
Xdomain_name: IDENTIFIER;
Xfield: IDENTIFIER;
Xfilename: PARM | IDENTIFIER; /* File name */
Xfname: IDENTIFIER; /* FUNCTION NAME */
Xf_key: IDENTIFIER;
Xhname: IDENTIFIER;
Xparm_name: IDENTIFIER;
X/* Field or Record path element */
Xpath_element: IDENTIFIER {strcat(path_name,$1);};
Xprog_name: IDENTIFIER;
Xrecord: IDENTIFIER;
Xsyn_name: IDENTIFIER;
Xtty: IDENTIFIER;
Xtime1: IDENTIFIER;
Xtime2: IDENTIFIER;
Xuser: PARM | IDENTIFIER;
X/*
Xrange_num: IDENTIFIER | INTEGER;
X*/
X%%
X#include "lex.yy.c"
END_OF_dsl.y
if test 17429 -ne `wc -c <dsl.y`; then
echo shar: \"dsl.y\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f ed0 -a "${1}" != "-c" ; then
echo shar: Will not over-write existing file \"ed0\"
else
echo shar: Extracting \"ed0\" \(53 characters\)
sed "s/^X//" >ed0 <<'END_OF_ed0'
Xed lex.yy.c > ed0.out <<EOF
X/output/
X.,.+2 d
Xw
Xq
XEOF
END_OF_ed0
if test 53 -ne `wc -c <ed0`; then
echo shar: \"ed0\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f ed1 -a "${1}" != "-c" ; then
echo shar: Will not over-write existing file \"ed1\"
else
echo shar: Extracting \"ed1\" \(122 characters\)
sed "s/^X//" >ed1 <<'END_OF_ed1'
Xed y.tab.h > ed1.out <<EOF
X/ALLFIELDS/
X.,$ d
X/BBEGIN/
X.s/BBEGIN/BEGIN/
X/NULLN/
X.s/NULLN/NULL/
X1
X/extern/
X1,.d
Xw y.h
Xq
XEOF
END_OF_ed1
if test 122 -ne `wc -c <ed1`; then
echo shar: \"ed1\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f ed2 -a "${1}" != "-c" ; then
echo shar: Will not over-write existing file \"ed2\"
else
echo shar: Extracting \"ed2\" \(244 characters\)
sed "s/^X//" >ed2 <<'END_OF_ed2'
Xset -x
Xecho $1>nt
Xed rwords >ed2.out <<EOF
X\$
X. s/, \$//
Xw
Xq
XEOF
Xed rnums >>ed2.out <<EOF
X\$
X. s/, \$//
Xw
Xq
XEOF
Xed tmprws.h >>ed2.out <<EOF
X/RWORDS/
X.s/[0-9][0-9]//
X.r nt
X-
X.,.+1j
X/\~\~/
X. d
X-
X. r rwords
X/\~\~/
X. d
X-
X. r rnums
Xw parser.h
Xq
XEOF
END_OF_ed2
if test 244 -ne `wc -c <ed2`; then
echo shar: \"ed2\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f gtok.h -a "${1}" != "-c" ; then
echo shar: Will not over-write existing file \"gtok.h\"
else
echo shar: Extracting \"gtok.h\" \(782 characters\)
sed "s/^X//" >gtok.h <<'END_OF_gtok.h'
X/*
XGenarate tokens for parse tree
XDDF Version 1.00
XBy Leroy G. Cain
XCopywrite 1986
X*/
X
X/* Tokens */
X/* expressions */
X#define T_EQ 0201
X#define T_NE 0202
X#define T_GT 0203
X#define T_NGT 0225
X#define T_GE 0204
X#define T_LT 0205
X#define T_NLT 0226
X#define T_LE 0206
X#define T_AND 0210
X#define T_OR 0211
X#define T_ADD 0212
X#define T_NEG 0101
X#define T_SUB 0213
X#define T_MUL 0214
X#define T_DIV 0215
X#define T_MOD 0221
X
X/* Constaints and varibles */
X#define T_FCHAR 0047
X#define T_PCHAR 0054
X#define T_CHAR 0057
X#define T_VAR 0050
X#define T_INT4 0070
X#define T_FLT8 0074
X
X/* Struct tokens */
X#define T_ROOT 0264
X#define T_ENDCOMMAND 0220
X#define T_AGHEAD 0217
X#define T_RESDOM 0200
X#define T_TLEND 0001
X#define T_QLEND 0002
END_OF_gtok.h
if test 782 -ne `wc -c <gtok.h`; then
echo shar: \"gtok.h\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f parser.c -a "${1}" != "-c" ; then
echo shar: Will not over-write existing file \"parser.c\"
else
echo shar: Extracting \"parser.c\" \(2255 characters\)
sed "s/^X//" >parser.c <<'END_OF_parser.c'
X/*
XParser
XVersion 1.0
X1986 Columbia Union College
XBy Leroy G. Cain
X*/
X
X# include "ddf.h"
X# include <stdio.h>
X# define U(x) x
X
Xstatic char *par_buf;
Xstatic char *par_sbuf;
X
Xextern char *yysptr, yysbuf[];
Xextern int yytchar;
Xextern int yylineno;
Xextern int ddf_err;
X
Xstatic unsigned char ptree[4096];
Xstatic unsigned char *ptree_ptr;
X
Xparse ( ddf_run, str )
XDDFRUN *ddf_run;
Xchar *str;
X{
Xregister int preturn;
Xint fd;
X
X par_buf = str;
X par_sbuf = str;
X ptree_ptr = ptree;
X preturn = yyparse();
X ddf_run->par_buf = ptree;
X ddf_run->buf_len = ptree_ptr-ptree;
X return !preturn;
X /*
X if( (preturn=ddf_parser()) && type >0 )
X pcovert(ptree,type);
X return preturn;
X */
X}
X
Xinput()
X{
X return
X (
X ( ( yytchar = ( yysptr > yysbuf ? U(*--yysptr) : *par_buf++ )
)
X == 10 ? (yylineno++, yytchar) : yytchar) == '\0' ? 0 :
yytchar
X );
X}
X
Xunput(c)
Xint c;
X{
X yytchar = c;
X if (yytchar=='\n') yylineno--;
X *yysptr++ = yytchar;
X}
X
Xoutput(c)
Xint c;
X{
X}
X
Xparerror(err)
Xint err;
X{
X ddf_err=err;
X}
X
Xputvar(s)
Xchar *s;
X{
Xint x;
X
X *ptree_ptr++ = strlen(s);
X for(;*s;*ptree_ptr++ = *s++);
X}
X
Xputstr(s)
Xchar *s;
X{
Xint x;
X
X *ptree_ptr++ = x = strlen(s)-2;
X *(s+x+1)= '\0';
X for(s++;*s;*ptree_ptr++ = *s++);
X}
X
Xputtok(n)
Xint n;
X{
X *ptree_ptr++ = n;
X}
X
Xputint(s)
Xchar *s;
X{
Xunion
X{
X long num;
X unsigned char n[4];
X} cludge;
X
X cludge.num = atoi(s);
X *ptree_ptr++ = cludge.n[0];
X *ptree_ptr++ = cludge.n[1];
X *ptree_ptr++ = cludge.n[2];
X *ptree_ptr++ = cludge.n[3];
X}
X
Xputreal(s)
Xchar *s;
X{
Xunion
X{
X double num;
X unsigned char n[8];
X} cludge;
X
X cludge.num = atof(s);
X *ptree_ptr++ = cludge.n[0];
X *ptree_ptr++ = cludge.n[1];
X *ptree_ptr++ = cludge.n[2];
X *ptree_ptr++ = cludge.n[3];
X *ptree_ptr++ = cludge.n[4];
X *ptree_ptr++ = cludge.n[5];
X *ptree_ptr++ = cludge.n[6];
X *ptree_ptr++ = cludge.n[7];
X}
X
X/* supplied by KMW */
X
Xyyerror (s)
Xchar *s;
X{
X fprintf (stderr, "%s\n", s);
X}
END_OF_parser.c
if test 2255 -ne `wc -c <parser.c`; then
echo shar: \"parser.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f phm.c -a "${1}" != "-c" ; then
echo shar: Will not over-write existing file \"phm.c\"
else
echo shar: Extracting \"phm.c\" \(432 characters\)
sed "s/^X//" >phm.c <<'END_OF_phm.c'
X#include <stdio.h>
X
Xmain()
X{
Xchar st[256];
Xchar j0, j1[32];
Xchar token[32];
Xint num;
Xint n=0;
XFILE *words;
XFILE *nums;
X
X words=fopen("rwords","w");
X nums=fopen("rnums","w");
X while ( gets(st)!=NULL)
X {
X sscanf(st,"%c %s %s %d ",&j0,j1,token,&num);
X fprintf(words,"\"%s\"%s",token,(n==5)? ",\n": ", ");
X fprintf(nums,"%d%s",num,(n==5)? ",\n": ", ");
X n=(n==5) ? 0 : ++n;
X }
X fprintf(words,"\n");
X fprintf(nums,"\n");
X exit(0);
X}
END_OF_phm.c
if test 432 -ne `wc -c <phm.c`; then
echo shar: \"phm.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f rwsearch.c -a "${1}" != "-c" ; then
echo shar: Will not over-write existing file \"rwsearch.c\"
else
echo shar: Extracting \"rwsearch.c\" \(637 characters\)
sed "s/^X//" >rwsearch.c <<'END_OF_rwsearch.c'
X# include <ctype.h>
Xrwsearch( str )
Xchar *str;
X{
Xint x;
Xint mid;
Xint low=0;
Xint high=RWORDS - 1;
X
X upshift(str);
X while(low <= high)
X {
X mid = (low+high)/2;
X if( !(x=strcmp(str, rwords[mid])) )
X return(rnums[mid]);
X else if( x<0 ) /* if lesser */
X high = mid-1;
X else if( x>0 ) /* if greater */
X low = mid+1;
X }
X return(IDENTIFIER);
X}
X
Xupshift(str)
Xchar *str;
X{
X for(;*str;str++)
X *str = (isupper(*str))? *str : toupper(*str);
X}
END_OF_rwsearch.c
if test 637 -ne `wc -c <rwsearch.c`; then
echo shar: \"rwsearch.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f testpar -a "${1}" != "-c" ; then
echo shar: Will not over-write existing file \"testpar\"
else
echo shar: Extracting \"testpar\" \(17 characters\)
sed "s/^X//" >testpar <<'END_OF_testpar'
Xtf <vtest2 |tpar
END_OF_testpar
if test 17 -ne `wc -c <testpar`; then
echo shar: \"testpar\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f tf.l -a "${1}" != "-c" ; then
echo shar: Will not over-write existing file \"tf.l\"
else
echo shar: Extracting \"tf.l\" \(17 characters\)
sed "s/^X//" >tf.l <<'END_OF_tf.l'
X%%
X#[0-9]+# ;
X%%
END_OF_tf.l
if test 17 -ne `wc -c <tf.l`; then
echo shar: \"tf.l\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f tmprws.h -a "${1}" != "-c" ; then
echo shar: Will not over-write existing file \"tmprws.h\"
else
echo shar: Extracting \"tmprws.h\" \(95 characters\)
sed "s/^X//" >tmprws.h <<'END_OF_tmprws.h'
X#define RWORDS 71
X#define FTOKEN 257
X
Xchar *rwords [] =
X{
X~~
X};
X
Xint rnums [] =
X{
X~~
X};
END_OF_tmprws.h
if test 95 -ne `wc -c <tmprws.h`; then
echo shar: \"tmprws.h\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f tpar.c -a "${1}" != "-c" ; then
echo shar: Will not over-write existing file \"tpar.c\"
else
echo shar: Extracting \"tpar.c\" \(2018 characters\)
sed "s/^X//" >tpar.c <<'END_OF_tpar.c'
X#include <ctype.h>
X#include <stdio.h>
X#include "ddf.h"
X
Xint ddf_err;
X
Xmain (argc,argv)
Xint argc;
Xchar *argv[];
X{
Xint x = 0;
XFILE *fd;
Xchar s[1024];
XDDFRUN partree;
X
X fd = fopen ("pt_file","w");
X for (printf ("%d>>", x++); getqu (s) && parse (&partree, s) > 0; x++)
X {
X fwrite (partree.par_buf, partree.buf_len, 1, fd);
X printf ("%d>>", x);
X }
X}
X
X/* old version; no longer used
Xgetq(s)
Xchar *s;
X{
X for(; (*s=getchar()) != EOF && *s != ';' ; s++);
X if(*s == EOF )
X return 0;
X else
X {
X *++s = '\0';
X return 1;
X }
X}
X*/
X
Xgetqu (s)
Xchar *s;
X{
Xstatic int getqtab [3] [5] =
X {
X {0,1,0,(int)'e',0},
X {1,1,2,1,1},
X {2,0,1,1,1}
X };
Xint tk;
Xint st = 0;
X
X *s = '\0';
X while ( (tk = getqt (s)) != EOF )
X {
X if (tk == 3 && !st)
X {
X return 1;
X }
X else
X st = getqtab[st] [tk];
X }
X return 0;
X}
X
Xgetqt (s)
Xchar *s;
X{
Xint c;
Xint value;
Xchar buf[256];
Xchar *sbuf=buf;
X
X if(isspace( (c=getchar()) ))
X value=0;
X else if( isalpha(c))
X {
X for(*buf=(islower(c)) ?toupper(c):c; isalpha( (c=getchar()) )
&&
X c != EOF ; *++sbuf = (islower(c)) ?toupper(c):c);
X *++sbuf ='\0';
X if(!strcmp(buf,"END"))
X value=2;
X else if(!strcmp(buf,"STORE"))
X value=1;
X else
X value=4;
X ungetc(c,stdin);
X strcat(s,buf);
X return value;
X }
X else if(c==';')
X value=3;
X else if(c == EOF)
X value = EOF;
X else
X value= 4;
X *sbuf = c;
X *++sbuf ='\0';
X strcat(s,buf);
X return value;
X}
END_OF_tpar.c
if test 2018 -ne `wc -c <tpar.c`; then
echo shar: \"tpar.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f vtest2 -a "${1}" != "-c" ; then
echo shar: Will not over-write existing file \"vtest2\"
else
echo shar: Extracting \"vtest2\" \(7485 characters\)
sed "s/^X//" >vtest2 <<'END_OF_vtest2'
X#0#
Xcreate domain s# is char5 where s# is not null;
X#1#
Xcreate domain p# is char6 where p# is not null;
X#2#
Xcreate domain j# is char4 where j# is not null;
X#3#
Xcreate domain name is char20;
X#4#
Xcreate domain status, weight, qty is int;
X#5#
Xcreate domain city is char15;
X#6#
Xcreate domain color is char6 where color in ( "green", "red", "blue");
X#7#
Xcreate table s
X primary (s#)
X ( s_name, status, city);
X
X#8#
Xcreate table p
X primary (p#)
X ( p_name, color, weight, city);
X
X#9#
Xcreate table j
X primary (j#)
X ( j_name, city);
X
X#10#
Xcreate table spj
X primary (s#, p#, j#)
X foreign (s# identifies s
X nulls not allowed
X delete of s restricted
X update of s.s# cascades)
X foreign (p# identifies p
X nulls not allowed
X delete of p restricted
X update of p.p# restricted)
X foreign (j# identifies j
X nulls not allowed
X delete of s restricted
X update of j.j# cascades)
X (qty);
X
X#11#
Xcreate unique index sx on s (s#);
X#12#
Xcreate unique index px on p (p#);
X#13#
Xcreate unique index jx on j (j#);
X#14#
Xcreate unique index spjx on spj (s#, p#, j#);
X
X#15#
Xinsert into s from sdate;
X#16#
Xinsert into p from pdate;
X#17#
Xinsert into j from jdate;
X#18#
Xinsert into spj from spjdate;
X
X#19#
Xcreate view sp
X as select s#, p# from spj;
X
X#20#
Xselect s#, status
Xfrom s
Xwhere city = 'Paris';
X
X#21#
Xselect p#
Xfrom sp;
X
X#22#
Xselect unique p#
Xfrom sp;
X
X#23#
Xselect p#, weight * 454
Xfrom p;
X
X#24#
Xselect p#, "Weight in grams =", weight * 454
Xfrom p;
X
X#25#
Xselect *
Xfrom s;
X
X#26#
Xselect s#, s_name, status, city
Xfrom s;
X
X#27#
Xselect s.*
Xfrom s;
X
X#28#
Xselect s#
Xfrom s
Xwhere city = "paris"
Xand status > 20;
X
X#29#
Xselect s#, status
Xfrom s
Xwhere city = "paris"
Xorder by status desc;
X
X#30#
Xselect p#, weight * 454
Xfrom p
Xorder by 2, P#;
X
X#31#
Xselect p#, pname, color, weight, city
Xfrom p
Xwhere weight between 16 and 19;
X
X#32#
Xselect p#, pname, color, weight, city
Xfrom p
Xwhere weight not between 16 and 19;
X
X#33#
Xselect p#, pname, color, weight, city
Xfrom p
Xwhere weight in (12, 16, 17);
X
X#34#
Xselect p#, pname, color, weight, city
Xfrom p
Xwhere weight not in (12, 16, 17);
X
X#35#
Xselect p#, pname, color, weight, city
Xfrom p
Xwhere weight = 12 or weight = 16 or weight = 17;
X
X#36#
Xselect p#, pname, color, weight, city
Xfrom p
Xwhere pname like 'C%';
X
X#37#
Xselect s#
Xfrom s
Xwhere status is null;
X
X#38#
Xselect s.*, p.*
Xfrom s, p
Xwhere s.city = p.city;
X
X#39#
Xselect s.*, p.*
Xfrom s, p
Xwhere s.city > p.city;
X
X#40#
Xselect s.*, p.*
Xfrom s, p
Xwhere s.city = p.city
Xand s.status != 20;
X
X#41#
Xselect s.s#, p.p#
Xfrom s, p
Xwhere s.city = p.city;
X
X#42#
Xselect unique s.*, p.*
Xfrom s, sp, p
Xwhere s.s# = sp.s#
Xand sp.p# = p.p#;
X
X#43#
Xselect first.s#, second.s#
Xfrom s first, s second
Xwhere first.city = second.city;
X
X#44#
Xselect first.s#, second.s#
Xfrom s first, s second
Xwhere first.city = second.city
Xand first.s# < second.s#;
X
X#45#
Xselect s#, p#, j#
Xfrom s, p, j
Xwhere not
X (s.city = p.city and p.city = j.city);
X
X#46#
Xselect s#, p#, j#
Xfrom s, p, j
Xwhere s.city != p.city
Xand p.city != j.city
Xand j.city != s.city;
X
X#47#
Xselect unique j#
Xfrom spj spjx
Xwhere not exists
X (select *
X from spj spjy
X where spjy.j# = spjx.j#
X and not exists
X (select *
X from spj spjz
X where spjz.p# = spjy.p#
X and spjz.s# = 'S1'
X )
X );
X
X#48#
Xselect unique j#
Xfrom spj spjx
Xwhere not exists
X (select *
X from spj spjy
X where exists
X (select *
X from spj spja
X where spja.s# = spjy.s#
X and spja.p# in
X (select p#
X from p
X where color = 'red')
X and not exists
X (select *
X from spj spjb
X where spjb.s# = spjy.s#
X and spjb.j# = spjx.j# )));
X
X#49#
Xselect unique s#
Xfrom spj
Xwhere p# in
X ( select p#
X from spj
X where s# in
X (select s#
X from spj
X where p# in
X (select p#
X from p
X where color = "red" )));
X
X#50#
Xselect unique s#
Xfrom spj spjx
Xwhere p# = 'p1'
Xand qty >
X ( select avg(qty)
X from spj spjy
X where p# = 'P1'
X and spjy.j# = spjx.j# );
X
X#51#
Xselect count(unique j#)
Xfrom spj
Xwhere s# = 's1';
X
X#52#
Xselect j#
Xfrom spj
Xwhere p# = 'p1'
Xgroup by j#
Xhaving avg (qty) >
X (select max(qty)
X from spj
X where j# = 'j1');
X
X#53#
Xselect city from s
Xunion
Xselect city from p
Xunion
Xselect city from j
Xorder by 1;
X
X#54#
Xselect p#, 'weight >16 lb'
Xfrom p
Xwhere weight >16
Xunion
Xselect p#, 'supplied by S2'
Xfrom sp
Xwhere s# = 'S2'
Xorder by 2, 1;
X
X#55#
Xselect p.p#, 'Weight in grams =', p.weight * 454, p.color,
X 'Max shipped quantity =', max(sp.qty)
Xfrom p, sp
Xwhere p.p# = sp.p#
Xand p.color in ('red', 'blue')
Xand sp.qty >200
Xgroup by p.p#, p.weight, p.color
Xhaving sum(qty) >350
Xorder by 6, p.p# desc;
X
X#56#
Xselect unique spjx.j#
Xfrom spj spjx
Xwhere exists
X (select *
X from spj spjy
X where spjy.p# = spjx.p#
X and spjy.s# = 's1');
X
X#57#
Xupdate p
Xset color = 'Orange'
XWhere color = 'Red';
X
X#58#
Xdelete
Xfrom j
Xwhere j# not in
X (select j#
X from spj );
X
X#59#
Xcreate table reds (s#);
X
X#60#
Xinsert into red (s#)
X select unique s#
X from spj, p
X where spj.p# = p.p#
X and color = 'Red';
X
X#61#
Xupdate spj
Xset qty = qty *1.1
Xwhere s# in
X (select s#
X from REDS );
X
X#62#
Xdrop table reds;
X
X#63#
Xdelete
Xfrom spj
Xwhere 'Rome' =
X (select city
X from j
X where j.j# = spj.j#);
X
X#64#
Xdelete
Xfrom j
Xwhere city = 'Rome';
X
X#65#
Xinsert
Xinto s (s#, s_name, city)
Xvalues ('S10', 'white', 'New York');
X
X#66#
Xinsert
Xinto s (s#, s_name, status, city)
Xvalues ('S11', 'white', NULL, 'New York');
X
X#67#
Xcreate view spv (s#, p#, qty )
X as select s#, p#, sum (qty)
X from spj
X group by s#, p#;
X
X#68#
Xcreate view jc (j#, city )
X as select unique j.j#, j.city
X from j, spj
X where j.j# = spj.j#
X and (spj.s# = 'S1' or spj.p# = 'P1' );
X
X#69#
Xcreate view jc (j#, city)
X as select j.j#, j.city
X from j
X where j.j# in
X (select j#
X from spj
X where s# = 'S1')
X and j.j# in
X (select j#
X from spj
X where p# = 'P1');
X
X#70#
Xcreate view non_colocated
X as select s#, p#
X from s, p
X where s.city != p.city;
X
X#71#
Xcreate view london_suppliers
X as select s#, s_name, status
X from s
X where city = "London";
X
X#72#
Xgrant select on table s to charly;
X
X#73#
Xgrant select , update(status, city) on table s
X to judy, jack, john;
X
X#74#
Xgrant createtab on database dbx to sharon;
X
X#75#
Xgrant select on table s to u2 with grant option;
X
X#76#
Xrevoke select on table s from u2;
X
X#77#
Xrevoke select, update on table s from u2;
X
X#78#
Xlock table s in exclusive mode;
X
X#79#
Xlock table p in share mode;
X
X#80#
Xstore program backup ( name = "p", fname = "/backup/p" )
Xlock table name in exclusive mode;
Xdump table name to fname;
Xlock table name in share mode;
Xcommit work;
Xend store;
X
X#81#
Xfirstprog ( "p", "/backup/p" );
END_OF_vtest2
if test 7485 -ne `wc -c <vtest2`; then
echo shar: \"vtest2\" unpacked with wrong size!
fi
# end of overwriting check
fi
echo shar: End of shell archive.
exit 0